using System;
using System.Collections.Generic;
using System.Text; 
using GameEditor.Common;

namespace TaskSystemClient.SPM
{
    public class UserGroup : SPMObject
    {
        private string userName;
        [Bind]
        public string UserName
        {
            get { return userName; }
            set { userName = value; }
        }
        private int active;
        [Bind]
        public int Active
        {
            get { return active; }
            set { active = value; }
        }
        private string dislayName;
        [Bind]
        public string DisplayName
        {
            get { return dislayName; }
            set { dislayName = value; }
        }

        private string user_ForCatalog=null;
        
        public string User_ForCatalog
        {
            get
            {
                if (user_ForCatalog==null)
                {
                    user_ForCatalog = "(" + Group1 + ")(" + UserName + ")";
                }
                return user_ForCatalog;
            }
        }

        private string group1;
        [Bind]
        public string Group1
        {
            get { return group1; }
            set { group1 = value; }
        }
        private string group2;
        [Bind]
        public string Group2
        {
            get { return group2; }
            set { group2 = value; }
        }
        private string group3;
        [Bind]
        public string Group3
        {
            get { return group3; }
            set { group3 = value; }
        }
        private int defaultView;
        [Bind]
        public int DefaultView
        {
            get { return defaultView; }
            set { defaultView = value; }
        }
        private string description;
        [Bind]
        public string Description
        {
            get { return description; }
            set { description = value; }
        }
        private DateTime userLastModifyTime;
        [Bind]
        public DateTime UserLastModifyTime
        {
            get { return userLastModifyTime; }
            set { userLastModifyTime = value; }
        }
        private string userLastModifyUser;
        [Bind]
        public string UserLastModifyUser
        {
            get { return userLastModifyUser; }
            set { userLastModifyUser = value; }
        }
        public override bool Commit(object context)
        {
            //CREATE Procedure spm_UpdateUserGroup
            //(
            //@OpUserName varchar(256),
            //@UserName varchar(256), --Key
            //@Active int,
            //@DisplayName varchar(256),
            //@Group1 varchar(256),
            //@Group2 varchar(256),
            //@Group3 varchar(256),
            //@DefaultView int
            //)
            //CommitContext cc = context as CommitContext;
            //ValueWrapper retval=
            //Utilities.SPInvoke<spm_UpdateUserGroup>(
            //    cc.Connection, cc.OperationUser,
            //    active, dislayName, group1, group2, group3, defaultView);

            SP.UpdateUserGroup(userName, active, dislayName, Utilities.SuppressString(group1), Utilities.SuppressString(group2), Utilities.SuppressString(group3), defaultView, Utilities.SuppressString(description));
            return true;

        }
    }
}
